<template>
	<view class="plan card record-content">
		<view class="title flex justify-between">
			<text>维修信息</text>
		</view>
		<view class="question">
			<view>
				<view class="record-item" v-show="taskInfo?.repairStartTime">
					<text>维修开始时间</text>
					<text>{{ taskInfo?.repairStartTime || "" }}</text>
				</view>
				<view class="record-item" v-show="taskInfo?.repairEndTime">
					<text>维修结束时间</text>
					<text>{{ taskInfo?.repairEndTime || "" }}</text>
				</view>

				<view class="record-item" v-show="taskInfo?.repairSituation">
					<text>维修情况说明</text>
					<text>{{ taskInfo?.repairSituation || "" }}</text>
				</view>
				<view class="record-item" v-show="taskInfo?.otherProblem">
					<text>维修中发现的其他问题</text>
					<text>{{ taskInfo?.otherProblem || "" }}</text>
				</view>
				<view class="record-item" v-show="taskInfo?.repairUseTime">
					<text>维修用时 (分钟)</text>
					<text>{{ taskInfo?.repairUseTime || "" }}</text>
				</view>
				<view class="record-item" v-show="taskInfo?.executeTeamName">
					<text>维修班组</text>
					<text>{{ taskInfo?.executeTeamName || "" }}</text>
				</view>
				<view class="record-item" v-show="taskInfo?.repairOrderPersons">
					<text>维修人</text>
					<text>
						{{ person || "" }}
					</text>
				</view>

				<view class="record-item" v-show="taskInfo?.parts?.length">
					<text>备件更换</text>
					<text
						style="text-decoration: underline; color: #0379ff"
						@click="
							jumpUrl(
								`/pages/eam/mold/plannedMaintenance/components/plannedAttachment?id=${taskInfo.id}&assetKind=${taskInfo.assetKind}`
							)
						">
						查看
					</text>
				</view>
				<view
					class="record-item"
					v-if="taskInfo?.fixBeforeFiles1.length">
					<text>维修前图片</text>
				</view>
				<view
					class="record-item"
					v-if="taskInfo?.fixBeforeFiles1.length">
					<upload-image
						:keys="44"
						:multiple="false"
						:isRead="true"
						:accept="accept"
						camera="back"
						:list="taskInfo?.fixBeforeFiles1"
						:capture="capture"
						folderName="eam/mold/eamPlannedMaintenance"
						style="margin-top: 5px"></upload-image>
				</view>
				
				<view
					class="record-item"
					v-if="taskInfo?.fixMidFiles1.length">
					<text>维修中</text>
				</view>
				<view
					class="record-item"
					v-if="taskInfo?.fixMidFiles1.length">
					<upload-image
						:keys="77"
						:multiple="false"
						:isRead="true"
						:accept="accept"
						camera="back"
						:list="taskInfo?.fixMidFiles1"
						:capture="capture"
						folderName="eam/mold/eamPlannedMaintenance"
						style="margin-top: 5px"></upload-image>
				</view>
				
				<view
					class="record-item"
					v-if="taskInfo?.fixTestFiles1.length">
					<text>试机</text>
				</view>
				<view
					class="record-item"
					v-if="taskInfo?.fixTestFiles1.length">
					<upload-image
						:keys="88"
						:multiple="false"
						:isRead="true"
						:accept="accept"
						camera="back"
						:list="taskInfo?.fixTestFiles1"
						:capture="capture"
						folderName="eam/mold/eamPlannedMaintenance"
						style="margin-top: 5px"></upload-image>
				</view>
				
				<view
					class="record-item"
					v-if="taskInfo?.fixAfterFiles1.length">
					<text>维修后图片</text>
				</view>
				<view
					class="record-item"
					v-if="taskInfo?.fixAfterFiles1.length">
					<upload-image
						:keys="55"
						:multiple="false"
						:isRead="true"
						:accept="accept"
						camera="back"
						:list="taskInfo?.fixAfterFiles1"
						:capture="capture"
						folderName="eam/mold/eamPlannedMaintenance"
						style="margin-top: 5px"></upload-image>
				</view>
			</view>
		</view>
	</view>
</template>

<script setup name="RepairHandleInfo">
import UploadImage from "@/components/upload-image-ssr.vue";
const props = defineProps({
	taskInfo: {
		type: Object,
		default: () => {},
	},
});
// 维修人员
let persons = ref([]);
let person = ref("");
function personList(arr) {
	persons.value = [];
	person.value = "";
	props.taskInfo?.repairOrderPersons?.forEach((item) => {
		persons.value.push(item?.personName);
	});
	person.value = persons?.value.join(",");
}
const { taskInfo } = toRefs(props);

if (taskInfo) {
	personList();
}
// 是否折叠
const isCollapse = ref(false);

// 摄像头参数设置
const capture = ref(["camera",'album']);
const accept = ref("image");

// 跳转至备件页面
function jumpUrl(url) {
	uni.navigateTo({
		url: url,
		fail: () => {
			uni.showToast({
				title: "敬请期待",
				icon: "error",
			});
		},
	});
}
</script>

<style lang="scss" scoped>
.card {
	background-color: #fff;
	margin: 10px 10px;
	border-radius: 8px;
	padding: 12px 12px;
	transition: all 300ms ease;
	box-shadow: 0 2px 6px rgba(3, 121, 255, 0.05);
}
.title {
	font-size: 16px;
	margin: 6px 0 14px;
	font-weight: bold;
	.u-icon {
		margin-right: 3px;
	}
}
</style>
